package xhhx.manager;

import com.google.protobuf.MessageLite;
import xhhx.cache.PlayerCache;
import xhhx.logic.ChangeNameProcessor;
import xhhx.logic.Processor;
import xhhx.network.MsgType;

import java.util.HashMap;
import java.util.Map;

public class MsgManager {
    private static Map<Integer, Processor<? extends MessageLite, ? extends MessageLite>> msgMap = new HashMap<>();

    public static void Init() {
        msgMap.put(MsgType.ChangeName.msgId, new ChangeNameProcessor());
    }

    public static void Close() {

    }

    public static MessageLite Processor(int msgId, MessageLite receive, PlayerCache playerCache) {
        return msgMap.get(msgId).Receive(receive, playerCache);
    }
}
